package com.md.api.authentication;

import com.md.model.request.IdRequest;
import com.md.model.request.authentication.users.AddUsersRequest;
import com.md.model.request.authentication.users.LoginRequest;
import com.md.model.request.authentication.users.RegisterUsersRequest;
import com.md.model.request.authentication.users.UpdateUsersRequest;
import com.md.model.response.authentication.users.RegisterUsersResponse;
import com.md.model.response.authentication.users.UsersLoginResponse;
import com.md.model.response.authentication.users.UsersResponse;
import com.md.model.system.CommonResult;
import com.md.value.constants.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.dom4j.DocumentException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.net.MalformedURLException;
import java.net.URISyntaxException;

/**
 * @author 刘骄阳
 * 2022-04-01 18:25
 */
@Api(tags = {ApiConstants.USERS})
public interface UsersApi {
  /**
   * 后台添加用户
   *
   * @param request 用户请求实体
   * @return 操作结果
   */
  @PostMapping("/users/insert")
  @ApiOperation("后台添加用户")
  CommonResult<Long> insert(@Validated @RequestBody @ApiParam("新增用户请求实体") AddUsersRequest request);

  /**
   * 后台添加用户
   *
   * @return 操作结果
   */
  @RequestMapping("/users/demo")
  @ApiOperation("后台添加用户")
  CommonResult<String> demo() throws MalformedURLException, URISyntaxException, DocumentException;

  /**
   * 后台添加用户
   *
   * @return 操作结果
   */
  @RequestMapping("/users/response")
  @ApiOperation("后台添加用户")
  CommonResult<Long> responses() throws MalformedURLException, URISyntaxException, DocumentException;

  /**
   * 注册
   *
   * @param request 用户请求实体
   * @return 操作结果
   */
  @PostMapping("/users/register")
  @ApiOperation("注册")
  CommonResult<RegisterUsersResponse> register(@Validated @RequestBody @ApiParam("用户注册请求实体") RegisterUsersRequest request);

  /**
   * 登录
   *
   * @param request 用户请求实体
   * @return 操作结果
   */
  @PostMapping("/users/login")
  @ApiOperation("登录")
  CommonResult<UsersLoginResponse> login(@RequestBody @ApiParam("用户登录请求实体") LoginRequest request);

  /**
   * 修改当前用户
   *
   * @param request 用户请求实体
   * @return 操作结果
   */
  @PostMapping("/users/update-self")
  @ApiOperation("修改当前用户")
  CommonResult<Void> updateSelf(@RequestBody @ApiParam("变更用户请求实体") UpdateUsersRequest request);

  /**
   * 更改其他用户
   *
   * @param request 用户请求实体
   * @return 操作结果
   */
  @PostMapping("/users/update-other")
  @ApiOperation("更改其他用户")
  CommonResult<Void> updateOther(@RequestBody @ApiParam("变更用户请求实体") UpdateUsersRequest request);

  /**
   * 查询用户信息
   *
   * @param request 用户请求实体
   * @return 操作结果
   */
  @PostMapping("/users/query")
  @ApiOperation("查询用户信息")
  CommonResult<UsersResponse> queryUserInfo(@RequestBody @ApiParam("查询用户请求实体") IdRequest request);
}
